/*******************************************************************************
  Main Source File

  Company:
    Microchip Technology Inc.

  File Name:
    main.c

  Summary:
    This file contains the "main" function for a project.

  Description:
    This file contains the "main" function for a project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state
    machines of all modules in the system
 *******************************************************************************/

// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "definitions.h"                // SYS function prototypes

// This is a Demo project running on PIC32CM1216MC00032 Curiosity Nano
// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

__attribute__((ramfunc, long_call)) void led_toggle(void) 
{
    // This is a function running from RAM, try add a break-point here
    (PORT_REGS->GROUP[0].PORT_OUTTGL = ((uint32_t)1U << 23U));
}

int main ( void )
{
    /* Initialize all modules */
    SYS_Initialize ( NULL );
    TC0_TimerCallbackRegister((TC_TIMER_CALLBACK)led_toggle, (uintptr_t)NULL);
    TC0_TimerStart();

    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );
    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/

